﻿@using Smarly.Forum.Bussines.Parsing
@using Smarly.Web.Areas.StapleForum.Helpers
@using Smarly.Web.Helpers
@model Smarly.Forum.Bussines.Model.ThreadModel.ThreadNote

@section css{
	@Styles.Render("~/bundles/css/markitup.forum")
}
@section script
{
	@Scripts.Render("~/bundles/js/markitup.forum")

	<script type="text/javascript">
		jQuery(function ($) {
			var $ta = $('#@Html.IdFor(x => x.NoteText)');
			rangyInputs.init();
			rangyInputs.enableTabIndentation($ta[0], "\t");
			$ta.markItUp(mySettings);
		})
	</script>

	<script type="text/javascript">
		$().ready(function () {
			var $form = $('#edit-note');
			var url = $form.attr('action');

			var rules = {};
			rules[url] = {
				'@Html.IdFor(x => x.NoteText)': { required: true },
			};

			var messages = {};
			messages[url] = {
				'@Html.IdFor(x => x.NoteText)': { required: "Поле не заполнено", },
			};

			$form.smarlyValidation({
				ext: {
					rules: rules,
					messages: messages,
				},
				onSuccess: function (data) {
					window.location.href = data.url;
					}
			});
		});
	</script>
}

@Html.Action("Crumbs", "Section", new {section = Model.Thread.SectionHashTag})

@Html.Partial("_GoogleAdsPartial")


<div class="row-fluid">
	<div class="span12">
		<div class="block-white crumb">
			<div class="block-content">
				<h5>@Model.Thread.Title</h5>
				@using (Html.BeginForm("EditNote", "Thread", FormMethod.Post, new { id = "edit-note" }))
		{
					@Html.HiddenFor(x => x.Id)

			 		<div class="input-name">Содержание:</div>
					@Html.TextArea(Html.IdFor(x => x.NoteText).ToString(), System.Web.HttpUtility.HtmlDecode(Model.NoteText.ToBbCode()))
					@Html.ValidationMessageCustomFor(x => x.NoteText)
			
					<div style="text-align: right;">
						<button type="submit" class="btn"><i class="icon-ok icon-white"></i>&nbsp;Сохранить</button>
						<a class="btn" href="@Url.ThreadAction(Model)"><i class="icon-remove"></i>&nbsp;Отменить</a>
					</div>
				}

				<blockquote>
					<h5 class="mb30">Горячие кнопки</h5>
					<div class="thread">
						<p><span class="hotkey">Ctrl + Enter</span> Новый параграф</p>
						<p><span class="hotkey">Shift + Enter</span> Перенос на новую строку</p>
						<p><span class="hotkey">Ctrl + L</span> Добавить ссылку</p>
						<p><span class="hotkey">Ctrl + Q</span> Добавить блок как блок "Горячие кнопки"</p>
						<p><span class="hotkey">Ctrl + B</span> Выделить текст жирным шрифтом</p>
						<p><span class="hotkey">Ctrl + I</span> Выделить текст курсивом</p>
						<p><span class="hotkey">Ctrl + U</span> Выделить текст подчеркнуть</p>
						<p><span class="hotkey">Ctrl + D</span> Выделить текст кодом</p>
					</div>
				</blockquote>
			</div>
		</div>
	</div>
</div>
